import ChapterSelector from "@/components/manga/chapters"; import Footer from "@/components/shared/footer"; import Head from "next/head"; import { useEffect, useState } from "react"; import { getServerSession } from "next-auth"; import { authOptions } from "../../api/auth/[...nextauth]"; import { mediaInfoQuery } from "@/lib/graphql/query"; import Modal from "@/components/modal"; import { signIn, useSession } from "next-auth/react"; import AniList from "@/components/media/aniList"; import ListEditor from "@/components/listEditor"; import MobileNav from "@/components/shared/MobileNav"; import Image from "next/image"; import DetailTop from "@/components/anime/mobile/topSection"; import Characters from "@/components/anime/charactersCard"; import Content from "@/components/home/content"; import { toast } from "sonner"; import axios from "axios"; import getAnifyInfo from "@/lib/anify/info"; import { redis } from "@/lib/redis"; import getMangaId from "@/lib/anify/getMangaId"; export default function Manga({ info, anifyData, color, chapterNotFound }) { const [domainUrl, setDomainUrl] = useState(""); const { data: session } = useSession(); const [loading, setLoading] = useState(false); const [progress, setProgress] = useState(0); const [statuses, setStatuses] = useState(null); const [watch, setWatch] = useState(); const [chapter, setChapter] = useState(null); const [open, setOpen] = useState(false); const rec = info?.recommendations?.nodes?.map( (data) => data.mediaRecommendation ); useEffect(() => { setDomainUrl(window.location.origin); }, []); useEffect(() => { if (chapterNotFound) { toast.error("Chapter not found"); const cleanUrl = window.location.origin + window.location.pathname; window.history.replaceState(null, null, cleanUrl); } }, [chapterNotFound]); useEffect(() => { async function fetchData() { try { setLoading(true); const { data } = await axios.get(`/api/v2/info?id=${anifyData.id}`); if (!data.chapters) { setLoading(false); return; } setChapter(data); setLoading(false); } catch (error) { console.error(error); } } fetchData(); return () => { setChapter(null); }; }, [info?.id]); function handleOpen() { setOpen(true); document.body.style.overflow = "hidden"; } function handleClose() { setOpen(false); document.body.style.overflow = "auto"; } return ( <> {info ? `Manga - ${ info.title.romaji || info.title.english || info.title.native }` : "Getting Info..."} handleClose()}>
{!session && (
Edit your list
)} {session && info && ( )}
{/*
*/}
{info?.bannerImage && ( banner anime )}
{!loading ? ( chapter?.chapters?.length > 0 ? ( ) : (

Oops!

It looks like this manga is not available.

) ) : (
)} {info?.characters?.edges?.length > 0 && (
)} {info && rec && rec?.length !== 0 && (
)}